#include "LinearAnimation.h"
#include "GraphicalElement.h"

LinearAnimation::LinearAnimation(const Position& start, const Position& end, unsigned long duration)
        : Animation(duration), start(start), end(end)
{
}

LinearAnimation::~LinearAnimation()
{
}

void LinearAnimation::update(double factor)
{
    if (factor > 1)
    {
        current = end;
        return;
    }
    current = start.scale(1.0 - factor) + end.scale(factor);
}

void LinearAnimation::render(const Position& parent)
{
    element->setPosition(current);
    Animation::render(parent);
}
